]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
osdWindow: Allow levels above 100%
authorDidier Roche <didrocks@ubuntu.com>
Tue, 31 Jul 2018 14:47:05 +0000 (16:47 +0200)
committerFlorian Müllner <florian.muellner@gmail.com>
Tue, 31 Jul 2018 18:14:11 +0000 (18:14 +0000)
Allow osd representing levels that can be more than 100% by accepting
an optional parameter setting that maximum level.
gnome-settings-daemon will use this to indicate volume levels above 100%,
which our own volume indicator will soon support as well.

js/ui/osdWindow.js
js/ui/shellDBus.js

index fe8cf780a67f44e6de3f40bd79776f97d764a011..9021c22d2c6fe492327c0689232506fe2a9fe45a 100644 (file)
@@ -22,6 +22,7 @@ var LevelBar = new Lang.Class({
 
     _init() {
         this._level = 0;
+        this._maxLevel = 100;
 
         let params = {
             styleClass: 'level',
@@ -38,9 +39,19 @@ var LevelBar = new Lang.Class({
     },
 
     set level(value) {
-        this._level = Math.max(0, Math.min(value, 100));
+        this._level = Math.max(0, Math.min(value, this._maxLevel));
 
         this.setValue(this._level / 100);
+    },
+
+    get maxLevel() {
+        return this._maxLevel;
+    },
+
+    set maxLevel(value) {
+        this._maxLevel = Math.max(100, value);
+
+        this.setMaximumValue(this._maxLevel / 100);
     }
 });
 
@@ -139,6 +150,12 @@ var OsdWindow = new Lang.Class({
         }
     },
 
+    setMaxLevel(maxLevel) {
+        if (maxLevel === undefined)
+            maxLevel = 100;
+        this._level.maxLevel = maxLevel;
+    },
+
     show() {
         if (!this._icon.gicon)
             return;
@@ -188,6 +205,7 @@ var OsdWindow = new Lang.Class({
         this.actor.hide();
         this.setLabel(null);
         this.setLevel(null);
+        this.setMaxLevel(null);
     },
 
     _relayout() {
@@ -232,24 +250,25 @@ var OsdWindowManager = new Lang.Class({
         this._osdWindows.length = Main.layoutManager.monitors.length;
     },
 
-    _showOsdWindow(monitorIndex, icon, label, level) {
+    _showOsdWindow(monitorIndex, icon, label, level, maxLevel) {
         this._osdWindows[monitorIndex].setIcon(icon);
         this._osdWindows[monitorIndex].setLabel(label);
         this._osdWindows[monitorIndex].setLevel(level);
+        this._osdWindows[monitorIndex].setMaxLevel(maxLevel);
         this._osdWindows[monitorIndex].show();
     },
 
-    show(monitorIndex, icon, label, level) {
+    show(monitorIndex, icon, label, level, maxLevel) {
         if (monitorIndex != -1) {
             for (let i = 0; i < this._osdWindows.length; i++) {
                 if (i == monitorIndex)
-                    this._showOsdWindow(i, icon, label, level);
+                    this._showOsdWindow(i, icon, label, level, maxLevel);
                 else
                     this._osdWindows[i].cancel();
             }
         } else {
             for (let i = 0; i < this._osdWindows.length; i++)
-                this._showOsdWindow(i, icon, label, level);
+                this._showOsdWindow(i, icon, label, level, maxLevel);
         }
     },
 
index c35e7f19c19c5a557b9fc1df55eb3263d7e476a5..55e1e573738549e8634cd99386d05323e05216a6 100644 (file)
@@ -148,12 +148,13 @@ var GnomeShell = new Lang.Class({
         let monitorIndex = params['monitor'] || -1;
         let label = params['label'] || undefined;
         let level = params['level'] || undefined;
+        let maxLevel = params['max_level'] || undefined;
 
         let icon = null;
         if (params['icon'])
             icon = Gio.Icon.new_for_string(params['icon']);
 
-        Main.osdWindowManager.show(monitorIndex, icon, label, level);
+        Main.osdWindowManager.show(monitorIndex, icon, label, level, maxLevel);
     },
 
     FocusApp(id) {